package com.dd.dc.entity.users;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.dd.dc.base.domain.DBaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 权限/菜单信息表
 * </p>
 *
 * @author JueDream
 * @since 2021-03-05
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("D_PERMISSION")
@ApiModel(value="DPermission对象", description="权限/菜单信息表")
public class DPermission extends DBaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "权限编号")
    @TableId(value = "P_ID", type = IdType.AUTO)
    private Integer pId;

    @ApiModelProperty(value = "权限名称")
    @TableField("P_NAME")
    private String pName;

    @ApiModelProperty(value = "权限类型 menu button")
    @TableField("P_TYPE")
    private String pType;

    @ApiModelProperty(value = "权限路径")
    @TableField("P_URL")
    private String pUrl;

    @ApiModelProperty(value = "权限规则 user:add")
    @TableField("P_RULE")
    private String pRule;

    @ApiModelProperty(value = "权限请求类型 POST/GET/DELETE")
    @TableField("P_REQ_TYPE")
    private String pReqType;

    @ApiModelProperty(value = "权限父节点")
    @TableField("P_PARENTID")
    private Integer pParentId;

    @ApiModelProperty(value = "权限父节点(多个-直到顶点)")
    @TableField("P_PARENTIDS")
    private String pParentIds;

    @ApiModelProperty(value = "权限是否可用 0-true 1-false")
    @TableField("P_AVAILABLE")
    private Integer pAvailable;

    @ApiModelProperty(value = "权限备注")
    @TableField("P_REMARK")
    private String pRemark;

    @ApiModelProperty(value = "菜单权限子集")
    @TableField(exist = false)
    private List<DPermission> children = new ArrayList<>();

    public DPermission(){}

    @Builder
    public DPermission(Integer pId, String pName, String pType, String pUrl, String pRule, Integer pParentId, String pParentIds, Integer pAvailable, String pRemark, Integer delFlg, String createBy, LocalDateTime createTime, String updateBy, LocalDateTime lastUpdateTime, List<DPermission> children) {
        this.pId = pId;
        this.pName = pName;
        this.pType = pType;
        this.pUrl = pUrl;
        this.pRule = pRule;
        this.pParentId = pParentId;
        this.pParentIds = pParentIds;
        this.pAvailable = pAvailable;
        this.pRemark = pRemark;
        this.delFlg = delFlg;
        this.createBy = createBy;
        this.createTime = createTime;
        this.updateBy = updateBy;
        this.lastUpdateTime = lastUpdateTime;
        this.children = children;
    }
}
